<?php


namespace App\Repository;

use Carbon\Carbon;

/**
 * 订单容器
 * Class OrderRepository
 * @package App\Repository
 */
class OrderRepository
{
    public function getRecentOrderCount(Account $account){
        $timestamp = Carbon::now()->subMinutes(5);
        return DB::table('orders')->where('account',$account->id)
            ->where('created_at','>=',$timestamp)
            ->count();

    }

    public function logOrder(Order $order){
        DB::table('orders')->insert(array(
            'account' => $order->account->id,
            'amount' => $order->amount,
            'created_at' => Carbon::now()
        ));
    }
}